package com.gmall.rabbitmq.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *
 */
@Configuration
public class RabbitMQConfig_Reliable {

    public static final String Exchange_Direct_Reliable = "Exchange_Direct_Reliable";

    public static final String Queue_Reliable = "Queue_Reliable";

    public static final String RoutingKey_Reliable = "RoutingKey_Reliable";

    @Bean(Exchange_Direct_Reliable)
    public Exchange Exchange_Direct_Reliable(){
        //durable:是否持久化
        return ExchangeBuilder.directExchange(Exchange_Direct_Reliable).durable(true).build();
    }

    @Bean(Queue_Reliable)
    public Queue Queue_Reliable(){
        //durable:是否持久化
        return QueueBuilder.durable(Queue_Reliable).build();
    }

    @Bean
    public Binding binding_direct_reliable(
            @Qualifier(Queue_Reliable) Queue queue,
            @Qualifier(Exchange_Direct_Reliable) Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with(RoutingKey_Reliable).noargs();
    }
}
